package front;

import java.io.IOException;
import java.net.UnknownHostException;
import java.util.List;

public class Test extends Thread{

	private Servicio servicio;
	
	public Test() throws UnknownHostException, IOException {
		servicio = new Servicio();
	}
	
	public void run() {
		try {
			List<Libro> lista = servicio.getListaLibros();
			for (Libro libro : lista) {
				servicio.comprarLibro(""+libro.getId_libro());
				System.out.println("Thread: "+ this + " compro el libro " + libro.getId_libro());
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String args[]) {
		for (int i=0; i<30; i++) {
			try {
				Test test = new Test();
				test.start();
			} catch (UnknownHostException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
